//
//  BaseNavigationViewController.swift
//  AudioToolProject
//
//  Created by 邹琳 on 2019/5/6.
//  Copyright © 2019 邹琳. All rights reserved.
//

import UIKit

class BaseNavigationViewController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

        self.navigationBar.barTintColor = MainColor
        self.navigationBar.tintColor = UIColor.white
        self.navigationBar.isTranslucent = false
        self.navigationBar.barStyle = .black
        
        self.interactivePopGestureRecognizer?.delegate = self
    }
    

    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        if self.viewControllers.count != 0{
            viewController.hidesBottomBarWhenPushed = true
        }
        super.pushViewController(viewController, animated: true)
    }
}

extension BaseNavigationViewController:UIGestureRecognizerDelegate{
    
    func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
        if gestureRecognizer == self.interactivePopGestureRecognizer{
            if self.viewControllers.count < 2{
                return false
            }
        }
        
        return true
    }
}


